//
//  AboutView.m
//  YTAutoLayout
//
//  Created by fly on 14/12/12.
//  Copyright (c) 2014年 fly. All rights reserved.
//

#import "AboutView.h"
#import "Masonry.h"

@implementation AboutView

-(instancetype)init
{
    if(self= [super init])
    {
        //        [self createAboutView];
        [self createView];
    }
    return self;
}

- (void)createView {
    self.backgroundColor = [UIColor whiteColor];
    UIImageView *imageView  =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_logo"]];
    [self addSubview:imageView];
    
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = @"中原油田普光分公司移动应用系统";
    nameLabel.font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:18];
    nameLabel.textAlignment = UITextAlignmentCenter;
    nameLabel.numberOfLines = 0;
    nameLabel.textColor = [UIColor blackColor];
    [self addSubview:nameLabel];
    
    UILabel *versionLabel = [[UILabel alloc] init];
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    version = [@"当前版本 " stringByAppendingString:version];
    versionLabel.font = [UIFont systemFontOfSize:12];
    versionLabel.textAlignment = UITextAlignmentCenter;
    versionLabel.numberOfLines = 0;
    versionLabel.textColor = [UIColor grayColor];
    versionLabel.text = version;
    [self addSubview:versionLabel];
    
    UILabel *supportLabel = [[UILabel alloc] init];
    supportLabel.text = @"技术支持:中原油田信息化管理中心";
    supportLabel.font = [UIFont systemFontOfSize:12];
    supportLabel.numberOfLines = 0;
    supportLabel.textAlignment = UITextAlignmentCenter;
    supportLabel.textColor = [UIColor grayColor];
    [self addSubview:supportLabel];
    
    UILabel *telLabel = [[UILabel alloc] init];
    telLabel.text = @"支持电话:4776804  4776805";
    telLabel.font = [UIFont systemFontOfSize:12];
    telLabel.numberOfLines = 0;
    telLabel.textAlignment = UITextAlignmentCenter;
    telLabel.textColor = [UIColor grayColor];
    [self addSubview:telLabel];
    
    UIImageView *downloadImageView = [[UIImageView alloc]init];
    downloadImageView.image = [UIImage imageNamed:@"download_image.png"];
    [self addSubview:downloadImageView];
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self).with.offset(100);
        make.size.height.mas_equalTo(CGSizeMake(60, 60));
    }];
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(imageView.mas_bottom).with.offset(5);
        make.height.mas_equalTo(@40);
        make.width.mas_equalTo(self);
    }];
    
    [versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(nameLabel.mas_bottom);
        make.height.mas_equalTo(@20);
        make.width.mas_equalTo(self);
    }];
    
    [downloadImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(versionLabel.mas_bottom).with.offset(10);
        make.width.mas_equalTo(@150);
        make.height.mas_equalTo(@150);
    }];
    
    
    [telLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.bottom.mas_equalTo(self.mas_bottom).with.offset(-10);
        make.height.mas_equalTo(@20);
        make.width.mas_equalTo(self);
    }];
    
    [supportLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.bottom.mas_equalTo(telLabel.mas_top);
        make.height.mas_equalTo(@20);
        make.width.mas_equalTo(self);
    }];
}


//-(void)createAboutView
//{
//    //239 239 241
//    self.backgroundColor = [UIColor whiteColor];
//
//    #pragma mark 创建控件
//    //1.UIImage
//    UIImageView *imageView  =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_about_logo"]];
//
//    //2.创建UIbuttons
//    UIButton *btnVersion = [[UIButton alloc] init];
//    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
//    version = [@"版本:" stringByAppendingString:version];
//    [btnVersion setTitle:version forState:UIControlStateNormal];
//    btnVersion.backgroundColor = [UIColor whiteColor];
//    [btnVersion setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//
//    UIButton *btnUpdata = [[UIButton alloc] init];
//    [btnUpdata setTitle:@"" forState:UIControlStateNormal];
//    btnUpdata.backgroundColor = [UIColor whiteColor];
//    [btnUpdata setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//
//    UIButton *btnSuport = [[UIButton alloc] init];
//    [btnSuport setTitle:@"技术支持：中原油田信息中心" forState:UIControlStateNormal];
//    btnSuport.backgroundColor = [UIColor whiteColor];
//    [btnSuport setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//
//
//    //添加到self
//    [self addSubview:imageView];
//    [self addSubview:btnSuport];
//    [self addSubview:btnUpdata];
//    [self addSubview:btnVersion];
//
//    for (UIView* itemView in self.subviews) {
//        itemView.translatesAutoresizingMaskIntoConstraints =NO;
//    }
//
//    #pragma mark设置约束
//    //imgeVIew
//    NSMutableArray *imageConstraint  = [[NSMutableArray alloc] init];
//    //水平约束
//    [imageConstraint addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"[imageView(==300)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(imageView)]];
//    //水平居中约束
//
//    [imageConstraint addObject:[NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
//
//    //垂直约束
//    [imageConstraint addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-74-[imageView(==100)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(imageView)]];
//
//    [self addConstraints:imageConstraint];
//
//    imageConstraint = nil;
//
//    //versionbutton
//    NSMutableArray *versionConstraint  = [[NSMutableArray alloc] init];
//    //水平约束
//    [versionConstraint addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"[btnVersion(==300)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(btnVersion)]];
//    //水平居中约束
//
//    [versionConstraint addObject:[NSLayoutConstraint constraintWithItem:btnVersion attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
//
//    //垂直约束
//    [versionConstraint addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[imageView]-40-[btnVersion(==30)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(imageView,btnVersion)]];
//
//    [self addConstraints:versionConstraint];
//    versionConstraint = nil;
//
//    //updataView
//    NSMutableArray *updataConstraint  = [[NSMutableArray alloc] init];
//    //水平约束
//    [updataConstraint addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"[btnUpdata(==1)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(btnUpdata)]];
//    //水平居中约束
//
//    [updataConstraint addObject:[NSLayoutConstraint constraintWithItem:btnUpdata attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
//
//    //垂直约束
//    [updataConstraint addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[btnVersion]-20-[btnUpdata(==1)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(btnVersion,btnUpdata)]];
//
//    [self addConstraints:updataConstraint];
//
//    updataConstraint = nil;
//    //suportView
//    NSMutableArray *suportConstraint  = [[NSMutableArray alloc] init];
//    //水平约束
//    [suportConstraint addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"[btnSuport(==300)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(btnSuport)]];
//    //水平居中约束
//
//    [suportConstraint addObject:[NSLayoutConstraint constraintWithItem:btnSuport attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
//
//    //垂直约束
//    [suportConstraint addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[btnUpdata]-15-[btnSuport(==30)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(btnUpdata,btnSuport)]];
//
//    [self addConstraints:suportConstraint];
//     suportConstraint = nil;
//}

@end
